package chixing.day20.work2;

import java.time.LocalDateTime;

public class FlashSale {
    private int productId;
    private double discount;
    private LocalDateTime startTime;
    private LocalDateTime endTime;

    public FlashSale(int productId, double discount, LocalDateTime startTime, LocalDateTime endTime) {
        this.productId = productId;
        this.discount = discount;
        this.startTime = startTime;
        this.endTime = endTime;
    }
    public FlashSale() {
    }

    public int getProductId() {
        return productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }
    public boolean isFlashSaleActive() {
        LocalDateTime now = LocalDateTime.now();
        return !now.isBefore(startTime) && !now.isAfter(endTime);
    }

    @Override
    public String toString() {
        return "FlashSale{" +
                "productId=" + productId +
                ", discount=" + discount +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                '}';
    }
}
